package ke24.ga.extension;

import ke24.ga.extension.adaptation.feedback.DeterministicLoadDistributionSwappingMutationOperator;

import org.jgap.Configuration;
import org.jgap.InvalidConfigurationException;

import com.softhinker.ke24.unit2.settings.SettingsPanel;
import com.softhinker.ke24.unit2.solution.SolutionPanel;


class MutationOperatorFactory {
    private Configuration config;
    private Parameters params;
    MutationOperatorFactory(Configuration config, Parameters params){
        this.config = config;
        this.params = params;
    }
    LoadDistributionSwappingMutationOperator getMutationOperatorFactory(String option) throws InvalidConfigurationException{
        if (SettingsPanel.DECREASING_STRING.equals(option)) {
            DeterministicLoadDistributionSwappingMutationOperator mutator =  new DeterministicLoadDistributionSwappingMutationOperator(config,params.getMutationRate());
            if (params.getNumEvolution() > 0) mutator.setExponentFactor(params.getNumEvolution());
            else mutator.setExponentFactor(1000);
            return mutator;
        }
        return new LoadDistributionSwappingMutationOperator(config,params.getMutationRate());
    }
}